A configuration of accommodating a substrate provided with a light emitting element emitting light, and a substrate provided with a light receiving element detecting the light emitted from the light emitting element, in a housing of a rotary encoder, has been known as a configuration of a rotary encoder (for example, Patent Literature 1).